# 1.有四个数字：1、2、3、4，能组成多少个互不相同且无重复数字的三位数？各是多少？
# for i in range(1, 5):
#     for j in range(1, 5):
#         for k in range(1, 5):
#             if i != j and i != k and j != k:
#                 print(i, j, k)

# 2.企业发放的奖金根据利润提成。利润(I)低于或等于10万元时，奖金可提10%；利润高于10万元，低于20万元时，
# 低于10万元的部分按10%提成，高于10万元的部分，可提成7.5%；20万到40万之间时，
# 高于20万元的部分，可提成5%；40万到60万之间时高于40万元的部分，可提成3%；60万到100万之间时，
# 高于60万元的部分，可提成1.5%，高于100万元时，超过100万元的部分按1%提成，从键盘输入当月利润I，
# 求应发放奖金总数？

# 方法一
# I = int(input("请输入利润："))
# bonus = 0
# if 0 < I <= 100000:
#     bonus = I * 0.1
# elif 100000 < I <= 200000:
#     bonus = (I - 100000) * 0.075 + 100000 * 0.1
# elif 200000 < I <= 400000:
#     bonus = (I - 200000) * 0.05 + 100000 * 0.075 + 100000 * 0.1
# elif 400000 < I <= 600000:
#     bonus = (I - 400000) * 0.03 + 200000 * 0.05 + 100000 * 0.075 + 100000 * 0.1
# elif 600000 < I <= 1000000:
#     bonus = (I - 600000) * 0.015 + 200000 * 0.03 + 200000 * 0.05 + 100000 * 0.075 + 100000 * 0.1
# elif I > 1000000:
#     bonus = (I - 1000000) * 0.01 + 400000 * 0.015 + 200000 * 0.03 + 200000 * 0.05 + 100000 * 0.075 + 100000 * 0.1
# print(bonus)

# 方法2
# i = int(input("请输入利润："))
# profit = [1000000, 600000, 400000, 200000, 100000, 0]
# rat = [0.01, 0.015, 0.03, 0.05, 0.075, 0.1]
# for j in range(0, 6):
#     if i > profit[j]:
#         bonus += (i - profit[j]) * rat[j]
#         print((i - profit[j]) * rat[j])
#         i = profit[j]
# print(bonus)

# 3. 一个整数，它加上100后是一个完全平方数，再加上168又是一个完全平方数，请问该数是多少？
# for i in range(2, 85):
#     if 168 % i == 0:
#         j = 168 // i
#         if i > j and (i + j) % 2 == 0 and (i - j) % 2 == 0:
#             m = (i + j) // 2
#             n = (i - j) // 2
#             x = n * n - 100
#             print(f"{x}")

# import math
# for x in range(1, 100000):
#     first = math.sqrt(x + 100)
#     second = math.sqrt(x + 100 + 168)
#     if first.is_integer() and second.is_integer():
#         print(f"满足条件的整数是：{x}")

# 4.输入某年某月某日，判断这一天是这一年的第几天？
# year = int(input("year:"))
# month = int(input("month:"))
# day = int(input("day:"))
#
# months = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334]
# if 0 < month <= 12:
#     sum = months[month - 1]
# else:
#     print('data error')
# sum += day
# if year % 400 == 0 or (year % 4 == 0 and year % 100 != 0):
#     if month > 2:
#         sum += 1
# print(f'it is the {sum}th day')

# 5.输入三个整数x,y,z，请把这三个数由小到大输出。
# l = []
# for i in range(3):
#     x = int(input())
#     l.append(x)
# l.sort()
# print(l)

# 6.斐波那契数列。
# fib = int(input())
# if fib == 1:
#     print(1)
# if fib == 2:
#     print(1)
# a = [1, 1]
# if fib > 2:
#     for i in range(2, fib):
#         a.append(a[-1]+a[-2])
# print(a)

# 7.将一个列表的数据复制到另一个列表中。
# a = [1, 2, 3]
# b = a[:]
# print(b)

# 8.输出 9*9 乘法口诀表。
# for i in range(1, 11):
#     print()
#     for j in range(1, i+1):
#         a = i * j
#         print(f'{j} * {i} = {a}', end='  ')

# 9.暂停一秒输出
# import time
#
# li = [1, 2, 3]
# for i in li:
#     print(i)
#     time.sleep(2)

# 10.暂停一秒输出，并格式化当前时间。
# import time
#
# print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())))
# time.sleep(1)
# print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())))

# 11.古典问题：有一对兔子，从出生后第3个月起每个月都生一对兔子，小兔子长到第三个月后每个月又生一对兔子，
# 假如兔子都不死，问每个月的兔子总数为多少？
# month1 = 1
# month2 = 1
# for i in range(1, 22):
#     print('%12ld %12ld' % (month1, month2), end=' ')
#     if (i % 3) == 0:
#         print('')
#     month1 = month1 + month2
#     month2 = month1 + month2

# 12.判断101-200之间有多少个素数，并输出所有素数。
# from math import sqrt
# from sys import stdout
# for i in range(101, 201):
#     k = int(sqrt(i+1))
#     for j in (2, k+1):
#         if i % j != 0:
#             print(i)

# 13.打印出所有的"水仙花数"，所谓"水仙花数"是指一个三位数，其各位数字立方和等于该数本身。
# 例如：153是一个"水仙花数"，因为153=1的三次方＋5的三次方＋3的三次方。
# for i in range(100, 1000):
#     j = i / 100
#     m = i / 10 % 10
#     n = i % 10
#     if i == j * j * j + m * m * m + n * n * n:
#         print(i)

# 14.将一个正整数分解质因数。例如：输入90,打印出90=2*3*3*5。
# n = int(input())
# while n not in [1]:
#     for index in range(2, n + 1):
#         if n % index == 0:
#             n //= index
#             if n == 1:
#                 print(index)
#             else:
#                 print('{} *'.format(index), end=' ')
#             break

# 15.利用条件运算符的嵌套来完成此题：学习成绩>=90分的同学用A表示，
# 60-89分之间的用B表示，60分以下的用C表示。
# score = int(input())
# if score >= 90:
#     print('A')
# elif 60 < score < 89:
#     print('B')
# else:
#     print('C')

# 16.输出指定格式的日期。
# import datetime
# if __name__ == '__main__':
#     print(datetime.date.today().strftime('%d/%m/%Y'))
#     Date = datetime.date(1941, 1, 5)
#     print(Date.strftime('%d/%m/%Y'))
#     Day = Date + datetime.timedelta(days=1)
#     print(Day.strftime('%d/%m/%Y'))
#     Birthday = Date.replace(year=Date.year+1)
#     print(Birthday.strftime('%d/%m/%Y'))

# 17.输入一行字符，分别统计出其中英文字母、空格、数字和其它字符的个数。
# str1 = input()
# zimu = 0
# space = 0
# shuzi = 0
# other = 0
# for i in str1:
#     if i.isalpha():
#         zimu += 1
#     elif i.isspace():
#         space += 1
#     elif  i.isdigit():
#         shuzi += 1
#     else:
#         other += 1
# print(zimu, space, shuzi, other)

# 18.求s=a+aa+aaa+aaaa+aa...a的值，其中a是一个数字。
# 例如2+22+222+2222+22222(此时共有5个数相加)，几个数相加由键盘控制
# Tn = 0
# Sn = []
# n = int(input())
# a = int(input())
# for i in range(n):
#     Tn = Tn + a
#     a = a * 10
#     Sn.append(Tn)
#     print(Sn)
# sum1 = sum(Sn)
# print(sum1)

# 19.一个数如果恰好等于它的因子之和，这个数就称为"完数"。例如6=1＋2＋3.编程找出1000以内的所有完数。

# li = []
# for n in range(2, 1001):
#     while n not in [1]:
#         for index in range(1, n):
#             if n % index == 0:
#                 n //= index
#                 if n == 1:
#                     li.append(index)
#     if n == sum(li):
#         print(f'{n}是完数')

# 20.一球从100米高度自由落下，每次落地后反跳回原高度的一半；
# 再落下，求它在第10次落地时，共经过多少米？第10次反弹多高？
# h = 100
# s = 0
# for i in range(1, 11):
#     if i == 1:
#         s += h
#     else:
#         s += h * 2
#     h /= 2
# print(s, h)

# 21.猴子吃桃问题：猴子第一天摘下若干个桃子，当即吃了一半，还不过瘾，
# 又多吃了一个第二天早上又将剩下的桃子吃掉一半，又多吃了一个。
# 以后每天早上都吃了前一天剩下的一半零一个。到第10天早上想再吃时，
# 见只剩下一个桃子了。求第一天共摘了多少。
# x2 = 1
# for i in range(9,0,-1):
#     x1 = (x2 + 1) * 2
#     x2 = x1
# print(x1)

# 22.两个乒乓球队进行比赛，各出三人。甲队为a,b,c三人，乙队为x,y,z三人。
# 已抽签决定比赛名单。有人向队员打听比赛的名单。a说他不和x比，c说他不和x,z比，
# 请编程序找出三队赛手的名单。
# for i in range(ord('x'),ord('z')+1):
#     for j in range(ord('x'),ord('z')+1):
#         if i != j:
#             for k in range(ord('x'),ord('z')+1):
#                 if i != k and (j != k):
#                     if i != ord('x') and k != ord('x') and k != ord('z'):
#                         print(chr(i), chr(j), chr(k))

# 23.打印出如下图案（菱形）:
#    *
#   ***
#  *****
# *******
#  *****
#   ***
#    *
# print('   * ')
# print('  ***')
# print(' *****')
# print('*******')
# print(' *****')
# print('  ***')
# print('   *')
# rows = 7
# for i in range(1, rows, 2):
#     space = ' ' * ((rows - i) // 2)
#     stars = '*' * i
#     print(space + stars)
# for i in range(rows, 0, -2):
#     space = ' ' * ((rows - i) // 2)
#     stars = '*' * i
#     print(space + stars)

# 24.有一分数序列：2/1，3/2，5/3，8/5，13/8，21/13...求出这个数列的前20项之和。
# a = 2
# b = 1
# s = 0
# for i in range(1,21):
#     s += a / b
#     t = a
#     a += b
#     b = t
# print(s)

# 25.求1+2!+3!+...+20!的和。
# l = 1
# k = 0
# for i in range(1, 21):
#     l *= i
#     k += l
# print(k)

# 26.利用递归方法求5!。
# def fact(j):
#     s = 0
#     if j == 1:
#         s = 1
#     else:
#         s = j * fact(j - 1)
#     return s
#
#
# print(fact(5))

# 27.利用递归函数调用方式，将所输入的5个字符，以相反顺序打印出来。
# def d(s, i):
#     print(s[i - 1])
#     d(s, i - 1)
#
#
# s = input()
# i = len(s)
# d(s, i)

# 28.有5个人坐在一起，问第五个人多少岁？他说比第4个人大2岁。问第4个人岁数，他说比第3个人大2岁。
# 问第三个人，又说比第2人大两岁。问第2个人，说比第一个人大两岁。最后问第一个人，他说是10岁。
# 请问第五个人多大？
# def age(n):
#     if n == 1: c = 10
#     else:
#         c = age(n - 1) + 2
#     return c
#
#
# print(age(5))

# 29.给一个不多于5位的正整数，要求：一、求它是几位数，二、逆序打印出各位数字。
# x = int(input())
# a = x // 10000
# b = x % 10000 // 1000
# c = x % 1000 // 100
# d = x % 100 // 10
# e = x % 10
# if e != 0 and a == b == c == d == 0:
#     print('它是一个个位数')
#     print(e)
# elif d != 0 and e != 0 and a == b == c == 0:
#     print('它是一个两位数')
#     print(e, d)
# elif c != 0 and d != 0 and e != 0 and a == b == 0:
#     print('它是一个三位数')
#     print(e, d, c)
# elif b != 0 and c != 0 and d != 0 and e != 0 and a == 0:
#     print('它是一个四位数')
#     print(e, d, c, b)
# elif a != 0 and b != 0 and c != 0 and d != 0 and e != 0:
#     print('它是一个五位数')
#     print(e, d, c, b, a)
# if a != 0:
#     print("5 位数：", e, d, c, b, a)
# elif b != 0:
#     print("4 位数：", e, d, c, b)
# elif c != 0:
#     print("3 位数：", e, d, c)
# elif d != 0:
#     print("2 位数：", e, d)
# else:
#     print("1 位数：", e)

# 30.一个5位数，判断它是不是回文数。即12321是回文数，个位与万位相同，十位与千位相同。
# a = int(input())
# b = str(a)
# for i in range(len(b) // 2):
#     if b[i] != b[-i - 1]:
#         print(f'{a}不是回文数')
#     else:
#         print(f'{a}是回文数')


# 31.请输入星期几的第一个字母来判断一下是星期几，如果第一个字母一样，则继续判断第二个字母。
# day = input()
# if day == 'M':
#     print('周一')
# elif day == 'T':
#     day = input()
#     if day == 'u':
#         print('周二')
#     elif day == 'h':
#         print('周四')
# elif day == 'W':
#     print('周三')
# elif day == 'F':
#     print('周五')
# elif day == 'S':
#     day = input()
#     if day == 'a':
#         print('周六')
#     elif day == 'u':
#         print('周日')

# 32.按相反的顺序输出列表的值。
# a = [1, 2, 3]
# # a.reverse()
# # print(a)
# for i in a[::-1]:
#     print(i)

# 33.按逗号分隔列表。
# a = [1, 2, 3]
# a1 = ','.join(str(i) for i in a)
# print(a1)

# 34.练习函数调用
# def output():
#     print('RUNOOB')
#
# def output1():
#     for i in range(0, 3):
#         output()
#
# output1()

# 35.文本颜色设置。
# class bcolor:
#     header = '\033[95m'
#     okblue = '\033[94m'
#     okgreen = '\033[92m'
#     warning = '\033[93m'
#     fail = '\033[91m'
#     endc = '\033[0m'
#     bold = '\033[1m'
#     underline = '\033[4m'
# print(bcolor.fail+'add')

# 36.求100之内的素数。
# for i in range(1, 101):
#     if i > 1:
#         for j in range(2, i):
#             if i % j == 0:
#                 break
#         else:
#             print(i)

# 37.对10个数进行排序。
# s = [34, 54, 26, 57, 2, 36, 28, 72, 89, 41]
# for i in range(0, 10):
#     min1 = i
#     for j in range(i+1, 10):
#         if s[min1] > s[j]:
#             min1 = j
#     s[i], s[min1] = s[min1], s[i]
# print(s)

# 38.求一个3*3矩阵主对角线元素之和。
# a = []
# sum = 0
# for i in range(0,3):
#     a.append([])
#     for j in range(0,3):
#         a[i].append(j)
# for i in range(0, 3):
#     sum += a[i][i]
# print(a)
# print(sum)

# 39.有一个已经排好序的数组。现输入一个数，要求按原来的规律将它插入数组中。
# a = [1, 4, 7, 14]
# number = int(input())
# for i in range(len(a)):
#     if number > a[-1]:
#         a.append(number)
#     if a[i-1] < number < a[i]:
#         a.insert(i, number)
# print(a)

# 40.将一个数组逆序输出。
# a = [1, 2, 3, 4]
# for i in range(len(a)//2):
#     a[i],a[-i-1] = a[-i-1],a[i]
# print(a)

# 41.模仿静态变量的用法。
# def varfunc():
#     var = 0
#     print('var = %d' % var)
#     var += 1
#
#
# if __name__ == '__main__':
#     for i in range(3):
#         varfunc()
#
#
# class Static:
#     StaticVar = 5
#     def varfunc(self):
#         self.StaticVar += 1
#         print(self.StaticVar)
#
# print(Static.StaticVar)
# a = Static()
# for i in range(3):
#     a.varfunc()

# 42.学习使用auto定义变量的用法。
# num = 2
# def autofunc():
#     num = 1
#     print('internal block num = %d' % num)
# for i in range(3):
#     print('The num = %d' % num)
#     num += 1
#     autofunc()

# 43.模仿静态变量(static)另一案例
# class Num:
#     nNum = 1
#
#     def inc(self):
#         self.nNum += 1
#         print('nNum = %d' % self.nNum)
# if __name__ == '__main__':
#     nNum = 2
#     inst = Num()
#     for i in range(3):
#         nNum += 1
#         print('The num = %d' % nNum)
#         inst.inc()

# 44.两个 3 行 3 列的矩阵，实现其对应位置的数据相加，并返回一个新矩阵：
# x = [[12, 7, 3],
#      [4, 5, 6],
#      [7, 8, 9]]
# y = [[5, 8, 1],
#      [6, 7, 3],
#      [4, 5, 9]]
# z = [[0, 0, 0],
#      [0, 0, 0],
#      [0, 0, 0]]
# for i in range(len(x)):
#     for j in range(len(x[0])):
#         z[i][j] = x[i][j] + y[i][j]
# for i in z:
#     print(i)

# 45.统计 1 到 100 之和。
# temp = 0
# for i in range(1,101):
#     temp += i
# print(temp)

# 46.求输入数字的平方，如果平方运算后小于 50 则退出。
# q = 0
# while 1:
#     number = int(input())
#     q = number * number
#     if q > 50:
#         print("退出")
#         break
#     else:
#         print(q)
#         break

# 47.两个变量值互换。
# a = 1
# b = 2
# a, b = b, a
# print(a, b)

# 48.数字比较。
# i = int(input())
# j = int(input())
# if i > j:
#     print(f'{i} > {j}')
# elif i < j:
#     print(f'{i} < {j}')
# elif i == j:
#     print(f'{i} = {j}')
# else:
#     print('unknown')

# 49.使用lambda来创建匿名函数。
# MAXIMUM = lambda x, y: (x > y) * x + (x < y) * y
# MINIMUM = lambda x, y: (x > y) * y + (x < y) * x
#
# a = 10
# b = 20
# print(MAXIMUM(a, b))
# print(MINIMUM(a, b))

# 50.输出一个随机数。
# import random
# print(random.randint(1, 5))

# 51.学习使用按位与 &
# a = 0x77
# b = a & 3
# print(b)

# 52.学习使用按位或 |
# a = 0o77
# b = a | 3
# print(a)
# print(b)

# 53.学习使用按位异或 ^
# a = 0o77
# b = a ^ 3
# print(a)
# print(b)

# 54.取一个整数a从右端开始的4〜7位。
# if __name__ == '__main__':
#     a = int(input('input a number:\n'))
#     b = a >> 4
#     c = ~(~0 << 4)
#     d = b & c
#     print('%o\t%o' % (a, d))

# 55.学习使用按位取反~
# a = 7
# b = ~a
#
# c = -7
# d = ~c
#
# print('变量 a 取反结果为： %d' % b)
# print('变量 c 取反结果为： %d' % d)

# 56.画图，学用circle画圆形。
# from tkinter import *
#
# canvas = Canvas(width=800, height=600, bg='yellow')
# canvas.pack(expand=YES, fill=BOTH)
# k = 1
# j = 1
# for i in range(0, 26):
#     canvas.create_oval(310 - k, 250 - k, 310 + k, 250 + k, width=1)
#     k += j
#     j += 0.3
# mainloop()

# 57.画图，学用line画直线。
# from tkinter import *
#
# canvas = Canvas(width=300, height=300, bg='pink')
# canvas.pack(expand=YES, fill=BOTH)
# x0 = 263
# y0 = 263
# y1 = 275
# x1 = 275
# for i in range(19):
#     canvas.create_line(x0, y0, x0, y1, width=1, fill='red')
#     x0 = x0 - 5
#     y0 = y0 - 5
#     x1 = x1 + 5
#     y1 = y1 + 5
#
# x0 = 263
# y1 = 275
# y0 = 263
# for i in range(21):
#     canvas.create_line(x0, y0, x0, y1, fill='red')
#     x0 += 5
#     y0 += 5
#     y1 += 5
#
# mainloop()

# 58.画图，学用rectangle画方形。
# from tkinter import *
#
# root = Tk()
# root.title('Canvas')
# canvas = Canvas(root, width=400, height=400, bg='pink')
# x0 = 263
# y0 = 263
# y1 = 275
# x1 = 275
# for i in range(19):
#     canvas.create_rectangle(x0, y0, x1, y1)
#     x0 -= 5
#     y0 -= 5
#     x1 += 5
#     y1 += 5
# canvas.pack()
# root.mainloop()

# 59.画图，综合例子。
# from tkinter import *
#
# canvas = Canvas(width=300, height=300, bg='green')
# canvas.pack(expand=YES, fill=BOTH)
# x0 = 150
# y0 = 100
# canvas.create_oval(x0 - 10, y0 - 10, x0 + 10, y0 + 10)
# canvas.create_oval(x0 - 20, y0 - 20, x0 + 20, y0 + 20)
# canvas.create_oval(x0 - 50, y0 - 50, x0 + 50, y0 + 50)
# import math
#
# B = 0.809
# for i in range(16):
#     a = 2 * math.pi / 16 * i
#     x = math.ceil(x0 + 48 * math.cos(a))
#     y = math.ceil(y0 + 48 * math.sin(a) * B)
#     canvas.create_line(x0, y0, x, y, fill='red')
# canvas.create_oval(x0 - 60, y0 - 60, x0 + 60, y0 + 60)
# for k in range(501):
#     for i in range(17):
#         a = (2 * math.pi / 16) * i + (2 * math.pi / 180) * k
#         x = math.ceil(x0 + 48 * math.cos(a))
#         y = math.ceil(y0 + 48 * math.sin(a) * B)
#         canvas.create_line(x0, y0, x, y, fill='red')
#     for j in range(51):
#         a = (2 * math.pi / 16) * j + (2 * math.pi / 180) * k - 1
#         x = math.ceil(x0 + 48 * math.cos(a))
#         y = math.ceil(y0 + 48 * math.sin(a) * B)
#         canvas.create_line(x0, y0, x, y, fill='red')
# mainloop()


# 60.计算字符串长度。
# str1 = 'adsfadfa'
# print(len(str1))

# 61.打印出杨辉三角形（要求打印出10行如下图）。
# a = []
# for i in range(10):
#     a.append([])
#     for j in range(10):
#         a[i].append(0)
# for i in range(10):
#     a[i][0] = 1
#     a[i][i] = 1
# for i in range(2, 10):
#     for j in range(1, i):
#         a[i][j] = a[i - 1][j - 1] + a[i - 1][j]
# from sys import stdout
# for i in range(10):
#     for j in range(i+1):
#         stdout.write(str(a[i][j]))
#         stdout.write(' ')
#     print()

# 62.查找字符串。
# str1 = 'afdsfa'
# str2 = 'af'
# print(str1.find(str2))

# 63.画椭圆。
# if __name__ == '__main__':
#     from tkinter import *
#
#     x = 360
#     y = 160
#     top = y - 30
#     bottom = y - 30
#
#     canvas = Canvas(width=400, height=600, bg='white')
#     for i in range(20):
#         canvas.create_oval(250 - top, 250 - bottom, 250 + top, 250 + bottom)
#         top -= 5
#         bottom += 5
#     canvas.pack()
#     mainloop()

# 64.利用ellipse 和 rectangle 画图。
# if __name__ == '__main__':
#     from tkinter import *
#     canvas = Canvas(width = 400,height = 600,bg = 'white')
#     left = 20
#     right = 50
#     top = 50
#     num = 15
#     for i in range(num):
#         canvas.create_oval(250 - right,250 - left,250 + right,250 + left)
#         canvas.create_oval(250 - 20,250 - top,250 + 20,250 + top)
#         canvas.create_rectangle(20 - 2 * i,20 - 2 * i,10 * (i + 2),10 * ( i + 2))
#         right += 5
#         left += 5
#         top += 10
#
#     canvas.pack()
#     mainloop()

# 65.一个最优美的图案。
# import math
#
#
# class PTS:
#     def __init__(self):
#         self.x = 0
#         self.y = 0
#
#
# points = []
#
# from tkinter import *
# def LineToDemo():
#     screenx = 400
#     screeny = 400
#     canvas = Canvas(width=screenx, height=screeny, bg='white')
#
#     AspectRatio = 0.85
#     MAXPTS = 15
#     h = screeny
#     w = screenx
#     xcenter = w / 2
#     ycenter = h / 2
#     radius = (h - 30) / (AspectRatio * 2) - 20
#     step = 360 / MAXPTS
#     angle = 0.0
#     for i in range(MAXPTS):
#         rads = angle * math.pi / 180.0
#         p = PTS()
#         p.x = xcenter + int(math.cos(rads) * radius)
#         p.y = ycenter - int(math.sin(rads) * radius * AspectRatio)
#         angle += step
#         points.append(p)
#     canvas.create_oval(xcenter - radius, ycenter - radius,
#                        xcenter + radius, ycenter + radius)
#     for i in range(MAXPTS):
#         for j in range(i, MAXPTS):
#             canvas.create_line(points[i].x, points[i].y, points[j].x, points[j].y)
#
#     canvas.pack()
#     mainloop()
#
#
# if __name__ == '__main__':
#     LineToDemo()

# 66.输入3个数a,b,c，按大小顺序输出。
# a = int(input())
# b = int(input())
# c = int(input())
#
#
# def n(n1, n2):
#     return n2, n1
#
#
# if a > b: a, b = n(a, b)
# if a > c: a, c = n(a, c)
# if b > c: b, c = n(b, c)
# print(a, b, c)

# 67.输入数组，最大的与第一个元素交换，最小的与最后一个元素交换，输出数组。
# li = [3, 4, 2, 6, 1, 5]
# max = li[0]
# min = li[0]
# p1 = 0
# p2 = 0
# for i in range(1, len(li)):
#     if li[i] > max:
#         max = li[i]
#         p1 = i
#     if li[i] < min:
#         min = li[i]
#         p2 = i
#
# li[p1], li[0] = li[0], li[p1]
# li[p2], li[-1] = li[-1], li[p2]
# print(li)

# 68.有 n 个整数，使其前面各数顺序向后移 m 个位置，最后 m 个数变成最前面的 m 个数
# n = int(input())
# a = []
# for i in range(n):
#     a.append(i)
# print(a)
# m = int(input())
# for i in range(0, n-m):
#     t = a[i]
#     a[i] = a[i+m]
#     a[i+m] = t
# print(a)

# 69.有n个人围成一圈，顺序排号。从第一个人开始报数（从1到3报数），
# 凡报到3的人退出圈子，问最后留下的是原来第几号的那位
# n = int(input())
# circle = []
# for i in range(n):
#     circle.append(i+1)
# print(circle)
# i = 0
# m = 0
# k = 0
# while m < n-1:
#     if circle[i] != 0:
#         k += 1
#     if k == 3:
#         circle[i] = 0
#         k=0
#         m += 1
#     i += 1
#     if i == n:
#         i = 0
# i = 0
# while circle[i] == 0:
#     i += 1
# print(circle[i])

# 70.写一个函数，求一个字符串的长度，在main函数中输入字符串，并输出其长度。
# def main():
#     str1 = input()
#     print(len(str1))
# if __name__ == '__main__':
#     main()

# 71.编写input()和output()函数输入，输出5个学生的数据记录。
# student = []
# for i in range(5):
#     student.append(['', '', []])
#
# for i in range(5):
#     student[i][0] = input()
#     student[i][1] = input()
#     for j in range(3):
#         student[i][2].append(int(input()))
# print(student)

# 72.创建一个链表。
# ptr = []
# for i in range(5):
#     num = int(input())
#     ptr.append(num)
# print(ptr)

# 73.反向输出一个链表。
# ptr = []
# for i in range(5):
#     num = int(input())
#     ptr.append(num)
# print(ptr)
# ptr.reverse()
# print(ptr)

# 74.反向输出一个链表。
# if __name__ == '__main__':
#     a = [1, 3, 2]
#     b = [3, 4, 5]
#     a.sort()
#     print(a)
#     print(a + b)
#     a.extend(b)
#     print(a)

# 75.放松一下，算一道简单的题目。
# for i in range(5):
#     n = 0
#     if i != 1: n += 1
#     if i == 3: n += 1
#     if i != 4: n += 1
#     if i == 4: n += 1
#     if n == 3: print(64 + i)

# 76.编写一个函数，输入n为偶数时，调用函数求1/2+1/4+...+1/n,
# 当输入n为奇数时，调用函数1/1+1/3+...+1/n
# def oddandeven(n):
#     s = 0.0
#     if n % 2 == 0:
#         for i in range(2, n+1, 2):
#             s += 1/n
#         return s
#     if n % 2 != 0:
#         for i in range(1, n+1, 2):
#             s += 1/n
#         return s
#
#
# if __name__ == '__main__':
#     odd = oddandeven(int(input()))
#     print(odd)

# 77.循环输出列表
# if __name__ == '__main__':
#     s = [1,2,3,4]
#     for i in range(len(s)):
#         print(s[i])

# 78.找到年龄最大的人，并输出。请找出程序中有什么问题。
# person = {'li':17,'zhao':26,'wang':30}
# m = 'li'
# for key in person.keys():
#     if person[m] < person[key]:
#         m = key
# print(m)

# 79.字符串排序。
# if __name__ == '__main__':
#     str1 = input()
#     str2 = input()
#     str3 = input()
#
#     if str1 > str2: str1,str2 = str2,str1
#     if str1 > str3: str1,str3 = str3,str1
#     if str2 > str3: str2,str3 = str3,str2
#     print(str1,str2,str3)

# 80.海滩上有一堆桃子，五只猴子来分。第一只猴子把这堆桃子平均分为五份，多了一个，
# 这只猴子把多的一个扔入海中，拿走了一份。第二只猴子把剩下的桃子又平均分成五份，
# 又多了一个，它同样把多的一个扔入海中，拿走了一份，第三、第四、第五只猴子都是这样做的，
# 问海滩上原来最少有多少个桃子？
# if __name__ == '__main__':
#     i = 0
#     j = 1
#     x = 0
#     while i < 5:
#         x = 4 * j
#         for i in range(0,5) :
#             if x%4 != 0:
#                 break
#             else :
#                 i += 1
#             x = (x/4) * 5 +1
#         j += 1
#     print(x)

# 81.809*??=800*??+9*?? 其中??代表的两位数, 809*??为四位数，8*??的结果为两位数，
# 9*??的结果为3位数。求??代表的两位数，及809*??后的结果。
# for i in range(10,100):
#     b = i * 809
#     if 1000 <= b < 10000 and 10 <= 8 * i <= 99 and 100 <= 9 * i <= 999:
#         print(i)

# 82.八进制转换为十进制
# n = 0
# p = input()
# for i in range(len(p)):
#     n = n * 8 + ord(p[i]) - ord('0')
# print(n)

# 83.求0—7所能组成的奇数个数
# sum = 4
# all = 4
# for i in range(2,9):
#     print(sum)
#     if i <= 2:
#         sum *= 7
#     else:
#         sum *= 8
#     all += sum
# print(all)

# 84.连接字符串。
# delimiter = ','
# mylist = ['Brazil', 'Russia', 'India', 'China']
# print(delimiter.join(mylist))

# 85.输入一个奇数，然后判断最少几个 9 除于该数的结果为整数。
# ji = int(input())
# n = 1
# q = 9
# m = 9
# for i in range(1,10):
#     if m % ji != 0:
#         m += q * 10**i
#         n += 1
# print(n)

# 86.两个字符串连接程序。
# if __name__ == '__main__':
#     a = "acegikm"
#     b = "bdfhjlnpq"
#
#     # 连接字符串
#     c = a + b
#     print(c)

# 87.回答结果（结构体变量传递）
# if __name__ == '__main__':
#     class student:
#         x = 0
#         c = 0
#     def f(stu):
#         stu.x = 20
#         stu.c = 'c'
#     a= student()
#     a.x = 3
#     a.c = 'a'
#     f(a)
#     print(a.x,a.c)

# 88.读取7个数（1—50）的整数值，每读取一个值，程序打印出该值个数的＊
# for i in range(1,8):
#     a = int(input())
#     if 1 <= a <= 50:
#         print(a * '*')

# 89.某个公司采用公用电话传递数据，数据是四位的整数，在传递过程中是加密的，加密规则如下：
# 每位数字都加上5,然后用和除以10的余数代替该数字，再将第一位和第四位交换，第二位和第三位交换。
# a = int(input())
# li = [a // 1000, a % 1000 // 100, a % 100 // 10, a % 10]
# for i in range(len(li)):
#     li[i] += 5
#     li[i] %= 10
# for i in range(0,2):
#     li[i],li[3-i] = li[3-i],li[i]
# print(li)

# 90.列表使用实例。
# testList = [10086, '中国移动', [1, 2, 4, 5]]
# print(len(testList))
# print(testList[1:])
# testList.append('i\'m new here!')
# print(len(testList))
# print(testList[-1])
# print(testList.pop(1))
# print(len(testList))
# print(testList)
# matrix = [[1, 2, 3],
#           [4, 5, 6],
#           [7, 8, 9]]
# print(matrix)
# print(matrix[1])
# col2 = [row[1] for row in matrix]  # get a  column from a matrix
# print(col2)
# col2even = [row[1] for row in matrix if row[1] % 2 == 0]  # filter odd item
# print(col2even)

# 91.时间函数举例1
# if __name__ == '__main__':
#     import time
#     print(time.ctime(time.time()))
#     print(time.asctime(time.localtime(time.time())))
#     print(time.asctime(time.gmtime(time.time())))

# 92.时间函数举例2
# if __name__ == '__main__':
#     import time
#
#     start = time.time()
#     for i in range(3000):
#         print(i)
#     end = time.time()
#     print(end - start)

# 93.时间函数举例3
# if __name__ == '__main__':
#     import time
#     start = time.clock()
#     for i in range(10000):
#         print(i)
#     end = time.clock()
#     print('different is %6.3f' % (end - start))

# 94.时间函数举例4,一个猜数游戏，判断一个人反应快慢。
# import time
# import random
# play_it = input('do you want to play a game.(\'y\'or \'n\')')
# if play_it == 'y':
#     number = random.randint(0,500)
#     start = time.time()
#     guess = int(input())
#     while guess != number:
#         if guess > number:
#             print('input a little small')
#             guess = int(input())
#         elif guess < number:
#             print('input a little bigger')
#             guess = int(input())
#     end = time.time()
#     if end - start < 30:
#         print('you are smart')
#     elif 30 < end - start < 50:
#         print('you are normal')
#     else:
#         print('you are stupid')

# 95.字符串日期转换为易读的日期格式。
# from dateutil import parser
# dt = parser.parse('Jul 28 2025 9:00AM')
# print(dt)

# 96.计算字符串中子串出现的次数
# str1 = 'stonemason'
# str2 = 'nema'
# count1 = str1.count(str2)
# print(count1)

# 97.从键盘输入一些字符，逐个把它们写到磁盘文件上，直到输入一个#为止。
# filename = input()
# fp = open(filename,'w')
# ch = input()
# while ch != '#':
#     fp.write(ch)
#     stdout.write(ch)
#     ch = input()
# fp.close()

# 98.从键盘输入一个字符串，将小写字母全部转换成大写字母，
# 然后输出到一个磁盘文件"test"中保存。
# fp = open('test.txt','w')
# string1 = input()
# string2 = string1.upper()
# fp.write(string2)
# fp = open('test.txt','r')
# print(fp.read())
# fp.close()

# 99.有两个磁盘文件A和B,各存放一行字母,要求把这两个文件中的信息合并(按字母顺序排列),
# 输出到一个新文件C中。
# fp1 = open('A.txt')
# a = fp1.read()
# fp2 = open('B.txt')
# b = fp2.read()
# fp1.close()
# fp2.close()
#
# fp = open('C.txt','w')
# l = list(a + b)
# l.sort()
# s = ''.join(l)
# fp.write(s)
# fp.close()

# 100.列表转换为字典。
# c = ['a','b']
# l = [1,2]
# print(dict[c:l])
